package cn.NewsServiceImpl;



import cn.NewsDao.NewsDao1;
import cn.NewsDaoImpl.NewsDaoImpl1;
import cn.NewsService.NewsService1;
import cn.entity.Detail;
import cn.entity.News1;


import java.util.ArrayList;
import java.util.List;

public class NewsServiceImpl1 implements NewsService1 {
    //实例化Dao接口
    private  NewsDao1 newsDao = new NewsDaoImpl1();

    @Override
    public boolean updateNews(News1 news) {
        return newsDao.update(news);
    }

    @Override
    public boolean addNews(News1 news) {
        return newsDao.add(news);
    }

    @Override
    public boolean deleteNews(int id) {
        return newsDao.delete(id);
    }

    @Override
    public List<News1> getNewsList1() {
        List<News1> list=newsDao.getNewsList();
        if (list.size()>0){
            return newsDao.getNewsList();
        }else {
            return new ArrayList<News1>();
        }

    }

    @Override
    public News1 selectNewsById(int id) {
        return newsDao.selectById(id);

    }

    @Override
    public List<News1> selectNewsPage(int index, int crencount) {
        return newsDao.selectPage(index,crencount);
    }

    @Override
    public List<News1> selectNewsPage1(Detail detail) {
        return newsDao.selectPage1(detail);
    }
}
